<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <title>客户开发计划</title>
    <link th:href="@{/localcss/crmlist.css}" href="../static/localcss/crmlist.css" rel="stylesheet">
</head>
<body>
<div layout:fragment="content">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            客户开发计划 <i class="fa fa-user"></i>
                            <small>
                                - 您可以通过搜索或者其他的筛选项对用户的信息进行编辑、删除等管理操作。^_^
                            </small>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form method="post" action="/plan/list" th:action="@{/plan/list}">
                            <input type="hidden" name="pageIndex" value="1"/>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">客户名称</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="name" type="text" th:value="${name}"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">负责人</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="linkMan" type="text" th:value="${linkMan}"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">概要</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="title" type="text" th:value="${title}"
                                                   class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                                </li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_content">
                        <p class="text-muted font-13 m-b-30"></p>
                        <div id="datatable-responsive_wrapper"
                             class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="datatable-responsive"
                                           class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                           cellspacing="0" width="100%" role="grid"
                                           aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="First name: activate to sort column descending"
                                                aria-sort="ascending">编号
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                客户名称
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                负责人
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                公司电话
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                状态
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                概要
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                操作
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr role="row" class="odd" th:each="chance:${chancePager.records}">
                                            <td tabindex="0" class="sorting_1" th:text="${chance.chcId}">usrId</td>
                                            <td th:text="${chance.chcCustName}">chcCustName</td>
                                            <td th:text="${chance.chcLinkman}">chcLinkman</td>
                                            <td th:text="${chance.chcTel}">chcTel</td>
                                            <td>
                                                <span th:if="${chance.chcStatus=='1'}">未分配</span>
                                                <span th:if="${chance.chcStatus=='2'}">开发中</span>
                                                <span th:if="${chance.chcStatus=='3'}">开发成功</span>
                                                <span th:if="${chance.chcStatus=='4'}">开发失败</span>
                                            </td>
                                            <td th:text="${chance.chcTitle}">chcTitle</td>
                                            <td>
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-danger">点击操作</button>
                                                    <button type="button" class="btn btn-danger dropdown-toggle"
                                                            data-toggle="dropdown" aria-expanded="false">
                                                        <span class="caret"></span>
                                                        <span class="sr-only">Toggle Dropdown</span>
                                                    </button>
                                                    <ul class="dropdown-menu" role="menu"
                                                        th:if="${chance.chcStatus=='3' or chance.chcStatus=='4'}">
                                                        <li><a class="editInfo" href="/plan/view?id=1"
                                                               th:href="@{/plan/view(id=${chance.chcId})}"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="查看">查看</a></li>
                                                    </ul>
                                                    <ul class="dropdown-menu" role="menu"
                                                        th:if="${chance.chcStatus=='2'}">
                                                        <li><a class="editInfo" href="/plan/add?id=1"
                                                               th:href="@{/plan/add(id=${chance.chcId})}"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="制定开发计划">制定开发计划</a></li>
                                                        <li><a class="editInfo" href="/plan/addPlanResult?id=1"
                                                               th:href="@{/plan/addPlanResult(id=${chance.chcId})}"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="执行开发计划">执行开发计划</a></li>
                                                        <li><a class="delInfo" id="del" href="#"
                                                               th:onclick="|successPlan(${chance.chcId})|"
                                                               data-toggle="tooltip" data-placement="top" title=""
                                                               data-original-title="开发成功">开发成功</a></li>
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-5">
                                    <div class="dataTables_info" id="datatable-responsive_info"
                                         role="status" aria-live="polite">共<span
                                            th:text="${chancePager.total }">1</span>条记录
                                        <span th:text="${chancePager.current }">1</span>/<span
                                                th:text="${chancePager.pages }">1</span>页
                                    </div>
                                </div>
                                <div class="col-sm-7">
                                    <div class="dataTables_paginate paging_simple_numbers"
                                         id="datatable-responsive_paginate">
                                        <ul class="pagination">
                                            <li class="paginate_button previous" th:if="${chancePager.current gt 1}"><a
                                                    href="javascript:page_nav(document.forms[0],1);"
                                                    aria-controls="datatable-responsive" data-dt-idx="0"
                                                    tabindex="0">首页</a>
                                            </li>
                                            <li class="paginate_button " th:if="${chancePager.current gt 1}"><a
                                                    href="#"
                                                    th:onclick="'javascript:page_nav(document.forms[0],'+${chancePager.current-1 }+');'"
                                                    aria-controls="datatable-responsive" data-dt-idx="1"
                                                    tabindex="0">上一页</a>
                                            </li>
                                            <li class="paginate_button "
                                                th:if="${(chancePager.current) lt chancePager.pages}"><a
                                                    href="#"
                                                    th:onclick="'javascript:page_nav(document.forms[0],'+${chancePager.current+1 }+');'"
                                                    aria-controls="datatable-responsive" data-dt-idx="1"
                                                    tabindex="0">下一页</a>
                                            </li>
                                            <li class="paginate_button next"
                                                th:if="${(chancePager.current) lt chancePager.pages}"><a
                                                    href="#"
                                                    th:onclick="'javascript:page_nav(document.forms[0],'+${chancePager.pages }+');'"
                                                    aria-controls="datatable-responsive" data-dt-idx="7"
                                                    tabindex="0">最后一页</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script layout:fragment="js" th:inline="javascript">
    function doDel(obj, id) {
        if (confirm("你确定需要删除该销售机会信息吗？")) {
            $.ajax({
                type: "GET",
                url: "/chance/delete",
                data: "id=" + id,
                dataType: "json",
                success: function (data) {
                    if (data.delResult == -2) {
                        alert("您不是销售机会的创建人，不允许删除！");
                    } else if (data.delResult == -1) {
                        alert("销售机会不是未分配状态，不允许删除！");
                    } else if (data.delResult == true) {//删除成功：移除删除行
                        alert("删除成功！");
                        $(obj).parents("tr").remove();
                    } else {
                        alert("对不起，删除失败！");
                    }
                },
                error: function (data) {
                    alert("对不起，删除失败！");
                }
            });
        }
    }
    //开发成功
    function successPlan(id) {
        if(confirm("你确定执行开发成功操作吗？")) {
            $.post("/plan/success", {id: id}, function (data) {
                if (data.delResult == true) {
                    alert("开发成功，已归档");
                    location.href = "/plan/list";
                } else {
                    alert("执行操作失败，请联系管理员！")
                }
            })
        }
    }
</script>
</html>